
layui.define('api',function(exports){
  var $ = layui.$
  ,layer = layui.layer
  ,laytpl = layui.laytpl
  ,setter = layui.setter
  ,view = layui.view
  ,admin = layui.admin
  ,api = layui.api

  //退出
  admin.events.logout = function(){
    let token = layui.sessionData(setter.tableName).token;
    if(token){
       //请求登入接口
       admin.req({
        url: api.host + api.logout,
        data:{token:layui.sessionData(setter.tableName).token},
        type: "POST",
        done: function (res) {
          sessionStorage.clear();
          window.location.replace(window.location.href);
          admin.exit();
        }
    });
    }else{
      sessionStorage.clear();
      window.location.replace(window.location.href);
      admin.exit();
    }
  };
  //对外暴露的接口
  exports('logout', {});
});